package com.itheima.Demo03;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Demo客户端交互 {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("192.168.50.113",13140);
        while (true) {
            //创建输出流;
            //BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
            OutputStream bos = s.getOutputStream();
            //键盘输入内容发送
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入内容:");
            String s1 = sc.nextLine();
            bos.write(s1.getBytes());
            //创建输入流;
            //BufferedInputStream bis = new BufferedInputStream(s.getInputStream());
            InputStream bis = s.getInputStream();
            byte[] arr = new byte[1024];

            int i = bis.read(arr);
            System.out.println("服务器端对我说:" + new String(arr, 0, i));

        }
    }
}
